package com.itwn.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class PassUtil {
    /**
     *
     * @param algorithmName 加密类型 MD5/SHA1
     * @param source 需要加密的原密码
     * @param saltValue 盐值
     * @param hashIterations 加密迭代次数
     * @return
     */
    public static String getHashPass(String algorithmName, Object source, Object saltValue, int hashIterations){
        Object salt=null;
        if (saltValue!=null) {
            salt = ByteSource.Util.bytes(saltValue);
        }
        SimpleHash simpleHash=new SimpleHash(algorithmName,source,salt,hashIterations);
        return simpleHash.toString();
    }
}
